package studio.raptor.extractor.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Created by liuyong8 on 2017/7/18.
 */
public class JdbcUtils {
  private static final Logger log = LoggerFactory.getLogger(JdbcUtils.class);

  public JdbcUtils() {}

  public static void close(Connection x) {
    if (x != null) {
      try {
        x.close();
      } catch (Exception e) {
        log.debug("close connection error", e);
      }

    }
  }

  public static void close(Statement x) {
    if (x != null) {
      try {
        x.close();
      } catch (Exception var2) {
        log.debug("close statement error", var2);
      }

    }
  }

  public static void close(ResultSet x) {
    if (x != null) {
      try {
        x.close();
      } catch (Exception var2) {
        log.debug("close result set error", var2);
      }

    }
  }

  public static void close(Closeable x) {
    if (x != null) {
      try {
        x.close();
      } catch (Exception var2) {
        log.debug("close error", var2);
      }

    }
  }
}
